package com.kgis.fm.common.manager
{
	import com.kgis.fm.flex.model.term.LegendEntry;
	import com.kgis.map.Map;
	import com.kgis.map.feature.Feature;
	import com.kgis.map.layer.FeatureLayer;
	import com.kgis.map.layer.Layer;
	
	import mx.collections.ArrayCollection;

	/**
	 * map与设备管理层的交互
	 * @author zhxiaomiao
	 * */
	public class MapCoreSupportManager
	{
		private static var _instance:MapCoreSupportManager=null;
		
		public static function getInstance():MapCoreSupportManager
		{
			if (!_instance)
			{
				_instance=new MapCoreSupportManager();
			}
			return _instance;
		}
		
		public function MapCoreSupportManager()
		{
			if (_instance)
			{
				throw new Error('MapCoreSupportManager is singleton');
			}
		}
		/**
		 * 
		 * @author zhxiaomiao
		 * */
		public static function getPrimarygeographicFeatureByFnoFid(fno:int,fid:Number,map:Map):Feature{
			var legendEntryList:ArrayCollection=MetaDataManager.getPrimarygeographicLayerByFno(fno);
			for each(var legendEntry:LegendEntry in legendEntryList){
				var layer:Layer=map.getLayerById(legendEntry.leno);
				if(layer is FeatureLayer){
					var feature:Feature=(layer as FeatureLayer).getFeatureById(fid);
					if(feature!=null){
						return feature;
					}
				}
			}
			return null;
		}
		
	}
}